home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / getCurrentPond.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  2.8 KB  |  96 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  2002
  22. //  Author:         DRB
  23. //
  24. // Description: Get selected or sole pond fluid node
  25. //    
  26.  
  27. proc int isUsablePond( string $fluid ){
  28.     int $solver = getAttr ($fluid + ".solver");
  29.     if( $solver < 2 ){
  30.         return false;
  31.     }
  32.     int $is2d          = getAttr ($fluid + ".is2d");
  33.     if( $is2d == 0 ){ return false; }
  34.  
  35.     int $heightField = getAttr ($fluid + ".heightField");
  36.     if( !$heightField ){ return false; }
  37.  
  38.     int $opacityInput = getAttr ($fluid + ".opacityInput");
  39.     if( $opacityInput != 5 ){ return false; }
  40.  
  41.     int $densityMethod = getAttr ($fluid + ".densityMethod");
  42.     if( $densityMethod != 2 ){ return false; }
  43.  
  44.     return( true );
  45. }
  46.  
  47. global proc string getCurrentPond()
  48. {
  49.     string $fluids[] = `ls -dag -type fluidShape`;
  50.     if( size($fluids) == 0 ){
  51.         warning( "There are currently no ponds in this scene");
  52.         return( "" );
  53.     }
  54.     // If only one fluid node, and it is suitable then use it
  55.     if( size( $fluids ) == 1 ){
  56.         if( isUsablePond( $fluids[0] ) ){
  57.             return( $fluids[0] );
  58.         } else {
  59.             warning( "There are currently no ponds in this scene");
  60.             return( "" );
  61.         }
  62.     }
  63.  
  64.     // There is more than one, so we need to disambiguate using the selection
  65.     string $usablePond = "";
  66.     int $i;
  67.     int $moreThanOneUsable = false;
  68.     for(  $i = 0; $i < size( $fluids ); $i++ ){
  69.         if( isUsablePond( $fluids[$i] ) ){
  70.             if( $usablePond == "" ){
  71.                 $usablePond = $fluids[$i];
  72.             } else {
  73.                 $moreThanOneUsable = true;
  74.                 break;
  75.             }
  76.         }
  77.     }
  78.     if( $usablePond == "" ){
  79.         warning( "There are currently no ponds in this scene");
  80.         return( "" );
  81.     }
  82.     if( !$moreThanOneUsable ){
  83.         return( $usablePond );
  84.     }
  85.  
  86.     // First check for selected fluids 
  87.     string $sel[] = `ls -sl -dag -type fluidShape`;
  88.     if( size($sel) > 0 ){
  89.         if( isUsablePond( $sel[0] ) ){
  90.             return( $sel[0] );
  91.         }
  92.     }
  93.     warning( "More than one suitable pond in scene.. select desired pond (fluid node) first" );
  94.     return( "" );    
  95. }
  96.